import time

from selenium import webdriver
from selenium.webdriver.common.by import By

drive = webdriver.Chrome()
drive.maximize_window()
drive.get("https://iviewui.com/view-ui-plus/component/form/checkbox")

# 通过text()定位
# drive.find_element(By.XPATH,"//span[text()='香蕉']").click()
# time.sleep(3)
# drive.find_element(By.XPATH,"//span[text()='苹果']").click()
# time.sleep(3)
# drive.find_element(By.XPATH,"//span[text()='西瓜']").click()
drive.find_element(By.XPATH,"//span[text()='香蕉']/preceding-sibling::span/input").click()
time.sleep(3)
drive.find_element(By.XPATH,"//span[text()='苹果']/preceding-sibling::span/input").click()
time.sleep(3)
drive.find_element(By.XPATH,"//span[text()='西瓜']/preceding-sibling::span/input").click()
time.sleep(3)
drive.close()
